<?php
namespace App\Http\Controllers\Api\AdminCode\Traits;

trait adminRequestUserData{

    /**
     * cms2ms 用户数据获取
     * author = [ domain,mp_openId,web_openId,app_openId,unionId,nickName,user_background_maps,avatarUrl,gender,id=>external_id,date ]
     */
    public function collectUserData($request){
        $data = ['domain'=>'','mp_openId'=>'','web_openId'=>'','app_openId'=>'', 'unionId'=>'', 'nickName'=>'', 'user_background_maps'=>'', 'avatarUrl'=>'', 'gender'=>0, 'external_id'=>'', 'date'=>''];

        $data['domain'] = $request->domain;

        $data['mp_openId'] = $request->author['mp_openId'] ?? '';
        $data['app_openId'] = $request->author['app_openId'] ?? '';
        $data['web_openId'] = $request->author['web_openId'] ?? '';

        $data['unionId'] = $request->author['unionId'] ?: '';
        $data['nickName'] = $request->author['nickName'];
        $data['user_background_maps'] = $request->author['user_background_maps'] ?: '';
        $data['avatarUrl'] = $request->author['avatarUrl'] ?: '';
        $data['gender'] = $request->author['gender'] ?: 0;
        $data['external_id'] = $request->author['id'];
        $data['date'] = $request->author['date'];
        return $data;
    }

}
